//
//  HBGetActivityListParser.m
//  HuoBao
//
//  Created by chaiyanan on 15/12/17.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "HBGetActivityListParser.h"
#import "HBGetActivityListInfo.h"
#import "HBGetActivityListItemInfo.h"

@implementation HBGetActivityListParser

-(ParserResult*)parseResponseDictionary:(NSDictionary *)responseDictionary
{
    LLog(@"responseDictionary:%@",responseDictionary);
    ParserResult* result=[[ParserResult alloc]init];
    NSNumber* codeObject=[responseDictionary objectForKey:Key_Code];
    if (codeObject)
    {
        NSInteger code = [codeObject integerValue];
        result.code = code;
        result.message = [responseDictionary objectForKey:Key_Msg];
        if (code == 0)
        {
            HBGetActivityListInfo *info = [[HBGetActivityListInfo alloc]init];
            NSArray *dataArray = [responseDictionary objectForKey:Key_Data];
            if (dataArray&&[dataArray isKindOfClass:[NSArray class]])
            {
                NSMutableArray *dataMulArray = [NSMutableArray arrayWithCapacity:dataArray.count];
                for (NSDictionary *dict in dataArray)
                {
                    HBGetActivityListItemInfo *listInfo = [[HBGetActivityListItemInfo alloc]init];
                    listInfo.activityImg = [DataTypeTranslate stringToString:dict[Key_activityImg]];
                    listInfo.activityName = [DataTypeTranslate stringToString:dict[Key_activityName]];
                    listInfo.activityUrl = [DataTypeTranslate numberToString:dict[Key_activityUrl]];
                    
                    [dataMulArray addObject:listInfo];
                }
                info.dataAry = dataMulArray;
                result.result = info;
            }
            else
            {
//                info.dataAry = [NSArray array];
                result.code=1;
                result.message=@"服务器数据异常";
            }
            
           
        }
        
    }
    else
    {
        result.code=1;
        result.message=@"服务器数据异常";
    }
    
    return result;
}


@end
